<?php
/**
 * 全局配置
 */

namespace App\backend\controllers\setting;

use App\backend\services\SettingServices;
use App\backend\controllers\AdminBaseController;
use Illuminate\Http\Request;

class SettingController extends AdminBaseController
{

    /**
     * 商城设置
     */
    public function setShop(Request $request)
    {

        if ($request->isMethod("POST")) {
            $result = SettingServices::setShop($request);
        }
        $result = SettingServices::getShop($request);

        if ($result) {
            return successJson('操作成功',$result);
        }
        return errorJson('操作失败');

    }

    /**
     * 订单设置
     */
    public function setOrder(Request $request)
    {

        if ($request->isMethod("POST")) {
            $result = SettingServices::setOrder($request);
        }
        $result = SettingServices::getOrder($request);

        if ($result) {
            return successJson('操作成功',$result);
        }
        return errorJson('操作失败');

    }

    /**
     * 物流设置
     */
    public function setExpress(Request $request)
    {

        if ($request->isMethod("POST")) {
            $result = SettingServices::setExpress($request);
        }
        $result = SettingServices::getExpress($request);

        if ($result) {
            return successJson('操作成功',$result);
        }
        return errorJson('操作失败');

    }

    /**
     * 短信设置
     */
    public function setSms(Request $request)
    {

        if ($request->isMethod("POST")) {
            $result = SettingServices::setSms($request);
        }
        $result = SettingServices::getSms($request);

        if ($result) {
            return successJson('操作成功',$result);
        }
        return errorJson('操作失败');

    }

    /**
     * 联系方式
     */
    public function setContact(Request $request)
    {

        if ($request->isMethod("POST")) {
            $result = SettingServices::setContact($request);
        }
        $result = SettingServices::getContact($request);

        if ($result) {
            return successJson('操作成功',$result);
        }
        return errorJson('操作失败');

    }

    /**
     * 优惠券
     */
    public function setCoupon(Request $request)
    {

        if ($request->isMethod("POST")) {
            $result = SettingServices::setCoupon($request);
        }
        $result = SettingServices::getCoupon($request);

        if ($result) {
            return successJson('操作成功',$result);
        }
        return errorJson('操作失败');

    }

    /**
     * 分享
     */
    public function setShare(Request $request)
    {

        if ($request->isMethod("POST")) {
            $result = SettingServices::setShare($request);
        }
        $result = SettingServices::getShare($request);

        if ($result) {
            return successJson('操作成功',$result);
        }
        return errorJson('操作失败');

    }

    /**
     * 地图设置
     */
    public function setMap(Request $request)
    {

        if ($request->isMethod("POST")) {
            $result = SettingServices::setMap($request);
        }
        $result = SettingServices::getMap($request);

        if ($result) {
            return successJson('操作成功',$result);
        }
        return errorJson('操作失败');

    }

    /**
     * 邮箱配置
     */
    public function setEmail(Request $request)
    {

        if ($request->isMethod("POST")) {
            $result = SettingServices::setEmail($request);
        }
        $result = SettingServices::getEmail($request);

        if ($result) {
            return successJson('操作成功',$result);
        }
        return errorJson('操作失败');

    }

    /**
     * 支付方式
     */
    public function setPay(Request $request)
    {

        if ($request->isMethod("POST")) {
            $result = SettingServices::setPay($request);
        }
        $result = SettingServices::getPay($request);

        if ($result) {
            return successJson('操作成功',$result);
        }
        return errorJson('操作失败');

    }

}
